{# 直播课 #}
{% set count = config.count %}
{% set courses = data('RecentLiveCourses',{'count':count}) %}
  <div class="es-box zhibo-side">
    <h2>{{ config.title|default(config.defaultTitle) }}</h2>

    {% if courses|length < 5 %}
    {% else %}
      <a class="class-nav left" href="#kechen-list" data-slide="prev">
        <span class="iconfont icon-zuosanjiaoxing"></span>
      </a>
      <a class="class-nav right" href="#kechen-list" data-slide="next">
        <span class="iconfont icon-yousanjiaoxing"></span>
      </a>
    {% endif %}

    <div id="zhibo-list" class="carousel slide" data-ride="carousel">
      <div class="carousel-inner">
        {% if courses %}
        {% if data('RecentLiveCourses',{'count':count})|slice(0, 5) %}
        {% set seq = 0 %}
          <ul class="class-list item active" data-role="pager-list">
            {% for zhibo in data('RecentLiveCourses',{'count':count})|slice(0, 5) %}
              {% if zhibo %}
              {% set seq = seq + 1 %}
                <li>
                  <a href="{{ path('course_show', {id:zhibo.id}) }}">
                    <span class="num-warn">{{ seq }}</span>
                    <h3>{{ zhibo.lesson.title|plain_text(15) }}</h3>
                         
                    <p>{{ zhibo.lesson.startTime|date('n月j日') }} {{ zhibo.lesson.startTime|date('H:i') }} -  {{ zhibo.lesson.endTime|date('H:i') }} 
                      {% set lesson = zhibo['lesson']|default(null) %}
                      {% if lesson and "now"|date("U") >= lesson.startTime and "now"|date("U") <= lesson.endTime %}
                        <span>直播中</span>
                      {% endif %}
                     </p>
                   </a>
                </li>
              {% endif %}  
            {% endfor %}
          </ul>
        {% endif %}  


        {% if data('RecentLiveCourses',{'count':count})|slice(5, 5) %}
          {% set sew = 5 %}
          <ul class="class-list item">
            {% for zhibo in data('RecentLiveCourses',{'count':count})|slice(5, 5) %}
              {% if zhibo %}
              {% set sew = sew + 1 %}
                <li>
                  <a href="{{ path('course_show', {id:zhibo.id}) }}">
                    <span class="num-warn">{{ sew }}</span>
                    <h3>{{ zhibo.lesson.title|plain_text(15) }}</h3>
                         
                    <p> {{ zhibo.lesson.startTime|date('H:i') }} -  {{ zhibo.lesson.endTime|date('H:i') }} 
                      {% set lesson = zhibo['lesson']|default(null) %}
                      {% if lesson and "now"|date("U") >= lesson.startTime and "now"|date("U") <= lesson.endTime %}
                        <span>直播中</span>
                      {% endif %}
                    </p>
                  </a>
                </li>
              {% endif %}  
            {% endfor %}
          </ul>

        {% endif %}  

        {% if data('RecentLiveCourses',{'count':count})|slice(10, 5) %}
          {% set see = 10 %}
          <ul class="class-list item">
          {% for zhibo in data('RecentLiveCourses',{'count':count})|slice(10, 5) %}
            {% if zhibo %}
            {% set see = see + 1 %}

               <li>
                    <a href="{{ path('course_show', {id:zhibo.id}) }}">
                          <span class="num-warn">{{ see }}</span>
                          <h3>{{ zhibo.lesson.title|plain_text(15) }}</h3>
                               
                           <p> {{ zhibo.lesson.startTime|date('H:i') }} -  {{ zhibo.lesson.endTime|date('H:i') }} 
                              {% set lesson = zhibo['lesson']|default(null) %}
                              {% if lesson and "now"|date("U") >= lesson.startTime and "now"|date("U") <= lesson.endTime %}
                                <span>直播中</span>
                              {% endif %}
                           </p>
                     </a>
              </li>

            {% endif %}  
          {% endfor %}
        </ul>
        {% endif %} 
        {% else %} 
          <div class="empty">还没有设置课程</div>
      {% endif %} 
      </div>
    </div>
  </div>